import http from '@/utils/http.js'

export const getTopCategoryAPI = (id) => {
  return http.get(`/category`, {
    params: {
      id
    }
  })
}

/**
 * 获取二级分类列表数据
 * @param id  分类id
 * @returns {*}
 */
export const getCategoryFilterAPI = (id) => {
  return http({
    url: '/category/sub/filter',
    params: {
      id
    }
  })
}

/**
 * 获取分类下的商品列表
 * @param data  {categoryId:分类id, pageNumber:页码, pageSize:页容量, sortField: 'publishTime' | 'orderNum' | 'evaluateNum'}
 * @returns {*}
 */
export const getSubCategoryAPI = (data) => {
  return http({
    url: '/category/goods/temporary',
    method: 'POST',
    data
  })
}
